package com.demo6;

public class Test2 {
    //匿名内部类的格式
    /*
    new类名或者接口名(){
        重写方法;
        };
     */
    public static void main(String[] args) {
        //整体我们可以理解为Swim接口的实现类对象
        //接口多态
        Swim swim=new Swim(){

            @Override
            public void swim() {
                System.out.println("重写了游泳的方法!");
            }
        };
        //编译看左边，运行看右边的原则
        swim.swim();


        new Swim(){

            @Override
            public void swim() {
                System.out.println("重写了游泳的方法!");
            }
        }.swim();
    }
}
